/*
 * @Description:增加、编辑开放字段表单组件
 * @Author: Rfan
 * @Date: 2022-08-20 12:08:53
 * @LastEditTime: 2022-08-23 11:12:12
 */

import { Form, Input, Select } from 'antd';
import JPSwitch from '@/components/JPComponents/JPSwitch';
import type { IMetadata } from '@/interfaces/metadata';

const { Option } = Select;

interface IFormItem {
  fieldList: IMetadata[];
}

const FormItem = (props: IFormItem) => {
  const { fieldList } = props;

  return (
    <>
      <Form.Item
        name="fieldId"
        label="字段名称"
        rules={[{ required: true, message: '请填写字段名称' }]}
      >
        <Select placeholder="请选择字段名称">
          {fieldList.map((field: any) => (
            <Option key={field.id} value={field.id}>
              {field.field_desc}
            </Option>
          ))}
        </Select>
      </Form.Item>
      {/* <Form.Item name="sortNo" label="排序优先级">
        <Input type="number" />
      </Form.Item> */}
      <Form.Item name="visible" label="是否可见" valuePropName="checked">
        <JPSwitch
          activeValue={1}
          inactiveValue={0}
          checkedChildren="可见"
          unCheckedChildren="隐藏"
        />
      </Form.Item>
      <Form.Item name="comment" label="备注">
        <Input.TextArea placeholder="" showCount maxLength={2000} />
      </Form.Item>
    </>
  );
};

export default FormItem;
